const Router = require('koa-router')
// **配置路由前缀**
const router = new Router({
  prefix: '/users'
})
const token = require('../../middleware/auth')
const UserCtl = require('../../controllers/user')

router.get('/', async (ctx, next) => {
  await UserCtl.find(ctx)
})

router.get('/:id', async (ctx) => {
 await UserCtl.findById(ctx)
})

// 新建一项
router.post('/', token ,async ctx => {
  await UserCtl.create(ctx)
})

router.put('/:id', token, async ctx => {
  console.log('11111');
  
  await UserCtl.updata(ctx)
})

router.delete('/:id',token, async (ctx) => {
  await UserCtl.delete(ctx)
})


module.exports = router
